package team.bluepen.supermarket.data.entity;

import team.bluepen.supermarket.data.dao.abstraction.Buildable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 数据表对象
 * @author Kai
 */
public class MarketTable implements Buildable<MarketTable>, Serializable {
    // 加个Market便于区分
    private String name;
    private final List<String> families = new ArrayList<>();

    public MarketTable() {}

    public MarketTable(String name, List<String> families) {
        this.name = name;
        this.families.addAll(families);
    }

    public MarketTable setName(String name) {
        this.name = name;
        return this;
    }

    public String getName() {
        return name;
    }

    public List<String> getFamilies() {
        return families;
    }

    public MarketTable setFamilies(List<String> families) {
        this.families.clear();
        this.families.addAll(families);
        return this;
    }

    public MarketTable setFamilies(String[] families) {
        this.families.clear();
        this.families.addAll(Arrays.asList(families));
        return this;
    }

    @Override
    public String toString() {
        return "MarketTable{" +
                "name='" + name + '\'' +
                ", families=" + families +
                '}';
    }

    @Override
    public MarketTable build() {
        return this;
    }
}
